<?php
class Eayso_EaysoCertRepo
{
	const TYPE_SAFE_HAVEN         = 100;
	const TYPE_SAFE_HAVEN_REFEREE = 101;
	const TYPE_SAFE_HAVEN_COACH   = 102;
	
	const TYPE_REFEREE_BADGE              = 200;
	const TYPE_REFEREE_BADGE_U8           = 210;
	const TYPE_REFEREE_BADGE_ASSISTANT    = 220;
	const TYPE_REFEREE_BADGE_REGIONAL     = 230;
	const TYPE_REFEREE_BADGE_INTERMEDIATE = 240;
	const TYPE_REFEREE_BADGE_ADVANCED     = 250;
	const TYPE_REFEREE_BADGE_NATIONAL_2   = 280;
	const TYPE_REFEREE_BADGE_NATIONAL     = 290;
	
	protected $certs = array(
		self::TYPE_SAFE_HAVEN_REFEREE => 'Safe Haven Referee',
		self::TYPE_SAFE_HAVEN_COACH   => 'Safe Haven Coach',
		self::TYPE_REFEREE_BADGE_U8   => 'U8 Official',
		self::TYPE_REFEREE_BADGE_ASSISTANT    => 'Assistant Referee',
		self::TYPE_REFEREE_BADGE_REGIONAL     => 'Regional Referee',
		self::TYPE_REFEREE_BADGE_INTERMEDIATE => 'Intermediate Referee',
		self::TYPE_REFEREE_BADGE_ADVANCED     => 'Advanced Referee',
		self::TYPE_REFEREE_BADGE_NATIONAL_2   => 'National 2 Referee',
		self::TYPE_REFEREE_BADGE_NATIONAL     => 'National Referee',
	);
	function getDesc($type) { return $this->certs[$type]; }
}
class ImportEaysoVolCerts extends Cerad_ExcelReader
{
    protected $map = array(
    	'Section'   => 'section',
    	'Area'      => 'area',
        'Region'    => 'region',
        'AYSOID'    => 'aysoid',
        'LastName'  => 'lname',
        'FirstName' => 'fname',
    	'Certificationdesc' => 'certDesc',
    	'Certificationdate' => 'certDate',
    );
    protected $certs = array(
    	'Safe Haven Referee' => array(
    		Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN => Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN_REFEREE,
    	),
    
    	'Z-Online Safe Haven Referee' => array(
    		Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN => Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN_REFEREE,
    	),
    
    	'U-8 Official'         => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_U8,
    	),
    	'Regional Referee'     => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_REGIONAL,
    	),
    	'Assistant Referee'    => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_ASSISTANT,
    	),
    	'Intermediate Referee' => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_INTERMEDIATE,
    	),
    	'Advanced Referee'     => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_ADVANCED,
    	),
    	'National Referee'     => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_NATIONAL,
    	),
    	'National 2 Referee'   => array(
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_NATIONAL_2,
    	),
    
    	'U-8 Official & Safe Haven Referee'      => array(
    		Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN    => Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN_REFEREE,
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_U8,
    	),
    	'Assistant Referee & Safe Haven Referee' => array(
    		Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN    => Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN_REFEREE,
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_ASSISTANT,
    	),
    	'Regional Referee & Safe Haven Referee'  => array(
    		Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN    => Eayso_EaysoCertRepo::TYPE_SAFE_HAVEN_REFEREE,
    		Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE => Eayso_EaysoCertRepo::TYPE_REFEREE_BADGE_REGIONAL,
    	),
    );
    protected $certRepo = NULL;
    protected function init()
    {
    	$this->certRepo = new Eayso_EaysoCertRepo();
    }
    public function processRowData($data)
    {
    	if (!isset($this->certs[$data->certDesc]))
    	{
        	echo "{$data->aysoid} {$data->lname} '{$data->certDesc}'\n";
        	die();
    	}
    	$certDate = $this->getDateFromExcelFormat($data->certDate);
    	if (strlen($certDate) != 8)
    	{
    		if (!$certDate) $certDate = ' UNKNOWN';
    		else 
    		{
        		echo "{$data->aysoid} {$data->lname} '{$data->certDesc}' '{$data->certDate}\n";
        		die();
    		}
    	}
        foreach($this->certs[$data->certDesc] as $cat => $type)
        {
        	$certDesc = $this->certRepo->getDesc($type);
        	
        	// See if already have a record
        	
        }
    }
}
?>